<!-- //我的卡卷 -->
<template>
    <view class="ticket">
		<tabbar :showLabel="false" :active="active" :tab="tab" @change_status="change_status" ></tabbar>
		<ticket-item :ticket="fun(ticket,active)" v-if="active == 0" @jump="jump"></ticket-item>
		<!-- 已使用 -->
		<ticket-item :ticket="fun(ticket,active)" v-if="active == 1" @jump="jump"></ticket-item>
		<!-- 已过期 -->
		<ticket-item :ticket="fun(ticket,active)" v-if="active == 2" @jump="jump"></ticket-item>
    </view>
</template>
<script>
export default {
    components: {
    },
    data() {
        return {
            active: 0,
            tab: [
                {
                    id: 0,
                    label: "待使用",
                },
                {
                    id: 1,
                    label: "已使用",
                },
                {
                    id: 2,
                    label: "已过期",
                },
            ],
            ticket: [
                {
                    id: 0,
					name: "优惠券",
                    text: "优惠券 10元代金券10元代金券",
                    num: 8800,
                    num1: "100000积分",
                    num2: "800",
                    status: 1,
                    text1: '待使用',
					button_status: 1,
					url: "/pages/user/tickey/conversion/index"
                },{
                    id: 5,
					name: "优惠券",
                    text: "优惠券 10元代金券10元代金券",
                    num: 8800,
                    num1: "100000积分",
                    num2: "800",
                    status: 0,
                    text1: '已使用',
					button_status: 1,
					url: "/pages/user/tickey/conversion/index"
                },{
                    id: 6,
					name: "优惠券",
                    text: "优惠券 10元代金券10元代金券",
                    num: 8800,
                    num1: "100000积分",
                    num2: "800",
                    status: 0,
                    text1: '已使用',
					button_status: 0,
					url: "/pages/user/tickey/conversion/index"
                },{
                    id: 7,
					name: "优惠券",
                    text: "优惠券 10元代金券10元代金券",
                    num: 8800,
                    num1: "100000积分",
                    num2: "800",
                    status: 0,
                    text1: '已过期',
					button_status: 1,
					url: "/pages/user/tickey/conversion/index"
                },
                {
                    id: 2,
					name: "通用卷",
                    text: "通用卷 1元代金券10元代金券",
                    num: 8800,
                    num1: "100000积分",
                    num2: "800",
                    status: 0,
                    text1: '已使用',
					button_status: 0,
					url: "/pages/user/tickey/conversion/index"
                },
                {
                    id: 3,
					name: "通用卷",
                    text: "通用卷 10元代金券10元代金券",
                    num: 8800,
                    num1: "100000积分",
                    num2: "800",
                    status: 0,
                    text1: '已过期',
					button_status: 1,
					url: "/pages/user/tickey/conversion/index"
                },
            ],
        };
    },
    computed: {},
    methods: {
        change_status(index) {
            this.active = index 
        },
        fun(val,active) {
            var arr = []
            val.forEach((item,index) => {
                if(item.text1 !== '已过期' && item.text1 !== '已使用' && active === 0){
                    arr.push(item)
                }
                else if(item.text1 === '已使用' && active === 1){
                    arr.push(item)
                }
                else if(item.text1 === '已过期' && active === 2){
                    arr.push(item)
                }
            });
            return arr
        },
		jump(val,text1) {
			if(text1 !== "已过期" && text1 !== "已使用"){
				uni.navigateTo({
					url: val
				})
			} else {
				// uni.showToast({
				//     title: '该卷不可使用',
				//     duration: 2000,
				// 	// icon: none,
					
				// });
				uni.showModal({
				    title: '提示',
				    content: '该卷不可使用',
				    // success: function (res) {
				    //     if (res.confirm) {
				    //         console.log('用户点击确定');
				    //     } else if (res.cancel) {
				    //         console.log('用户点击取消');
				    //     }
				    // }
				});
			}
		}
    },
    beforeCreate() {},
    created() {},
    beforeMount() {},
    mounted() {
		// console.log("ticket",this.ticket)
    },
    beforeUpdate() {},
    updated() {},
    beforeDestroy() {},
    destroyed() {},
};
</script>
<style scoped lang='scss'>
.ticket{
	width: 100%;
	height: 100%;
	padding: 0 32rpx 16rpx;
	box-sizing: border-box;
}
</style>
<style>
	page{
		background-color: #fff;
	}
</style>